package com.taxicall.client;

import com.taxicall.entities.TaxiLocation;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;


public class MyArrayAdapter extends ArrayAdapter<TaxiLocation> {

	private final Context context;
	private final TaxiLocation[] data;
	
	public MyArrayAdapter(Context context, TaxiLocation[] data) {
		super(context, R.layout.rowlayout, data);
		this.context = context;
		this.data = data;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
		TextView tvName = (TextView) rowView.findViewById(R.id.tspName);
		TextView tvAddr = (TextView) rowView.findViewById(R.id.tspAddress);
		tvName.setText(data[position].getName());
		tvAddr.setText(data[position].getAddress());
		return rowView;
	}
}
